﻿using System;
using System.Collections.Generic;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.Text;

namespace WCFServer
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                WebServiceHost serviceHost = new WebServiceHost(typeof(WebDAVServer));
                ServiceDebugBehavior sdb = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
                sdb.HttpHelpPageEnabled = false;

                serviceHost.Open();
                InvalidatePeerNode(serviceHost.BaseAddresses[0]);
                Console.ReadLine();
                serviceHost.Close();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                Console.ReadLine();
            }
        }

        static void InvalidatePeerNode(Uri address)
        {
            try
            {
                WebRequest reqPOST = System.Net.WebRequest.Create(address.ToString() + "/UpdateServer");
                reqPOST.Method = "UpdateServer"; // Устанавливаем метод передачи данных в POST
                reqPOST.Timeout = 120000; // Устанавливаем таймаут соединения            
                WebResponse resp = reqPOST.GetResponse();
            }
            catch
            {
            }
        }

    }
}
